<template>
	<view class="page">
		<view class="om_hd_fix">
			<uni-search-bar placeholder="请输入关键字" style="background-color: rgb(15, 174, 255);" @confirm="confirm"></uni-search-bar>
		</view>
		<view class="page__bd" style="padding-top: 100rpx;">
			<uni-list>
				<view v-for="(item, index) in datas" :key="index">
					<uni-list-item 
						@click="itemtap(item)"
						:showArrow="false" 
						:title="item.instname">
					</uni-list-item>
				</view>
			</uni-list>
		 </view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				searchStr:"",
				datas:[]
			}
		},
		methods: {
			confirm(e){
				let _that = this;
				if (e.value) {
				  if (!this.searchStr || (this.searchStr && this.searchStr != e.value.trim())) {
					this.searchStr = e.value.trim()
					_that.om.request('tinstitution/findNotBoard1',{
						instName: this.searchStr
					},'post').then(res=>{
						if (res) {
						  if (res.length) {
						    _that.datas = res
						  } else {
						    _that.datas= []
						  }
						}
					})
				  }else{
					_that.datas= []
					}
				}else{
					_that.datas= []
				}
			}, //点击选型确定input值
			  itemtap(item) {
			    let costinst = {
			      id:item.id,
			      name: item.instname,
			    }
			    uni.setStorage({
			      key: 'overtime-costinst',
			      data: costinst
			    })
			    //回主页面
			    uni.navigateBack();
			  }
		}
	}
</script>

<style>

</style>
